package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos=new FileOutputStream("u.txt");
        OutputStreamWriter bos=new OutputStreamWriter(fos,StandardCharsets.UTF_8);
        BufferedWriter boo=new BufferedWriter(bos);
        PrintWriter pw=new PrintWriter(boo,true);
        Scanner scan=new Scanner(System.in);

        System.out.println("请开始输入内容，exit时结束");
        while (true){
            String line=scan.nextLine();
            if ("exit".equals(line)){
                break;
            }
            pw.println(line);

        }
        pw.close();




//        PrintWriter pw=new PrintWriter("nnn.txt");
//        pw.println("和回去看全国房价烤漆房");
//        pw.println("jsakdakdaoq");
//        System.out.println("输出完毕");
//        pw.close();

//        FileOutputStream fos=new FileOutputStream("nnn.txt");//低级流 （文件流）
//       OutputStreamWriter obs=new OutputStreamWriter(fos, StandardCharsets.UTF_8);//(高级流)转换流
//       BufferedWriter bos=new BufferedWriter(obs);//缓冲字符流（高级流 ）
//        bos.write("和回去看全国房价烤漆房");
//        bos.write("jsakdakdaoq");
//        System.out.println("写出完毕");
//        bos.close();

    }
}
